<template>
	<view>
		<view class="top">
			<view class="top1">
				<image :src="bindUrls(cai_info.image)" mode=""></image>
			</view>
			<view class="top2">
				<view class="top2Txt1">
					{{ cai_info.cai_name }}
				</view>
				<view class="top2Txt2">
					{{ cai_info.basic_amount }}元
				</view>
				<view class="top2Txt3">
					{{ cai_info.unit_name }}
				</view>
			</view>
		</view>
		<view class="line"></view>
		<view class="topSe">
			<view class="inputInfo">
				<view class="inputIcon">
					<u-icon name="search" color="#979797" size="32"></u-icon>
				</view>
				<view class="inputHtml">
					<input type="text" v-model="keyword" @confirm="kehuAndCai" placeholder="请输入姓名" />
				</view>
			</view>
		</view>
		<view class="lineList">
			<view class="list" v-for="(item,index) in kehuList" :key="index">
				<view class="leftView">
					{{ item.realname }}
				</view>
				<view class="rightView">
					<view class="txt" v-if="item.islook" @click="setJan(index)">
						可见
					</view>
					<view class="txt bkj" v-if="!item.islook" @click="setJan(index)">
						不可见
					</view>
				</view>
			</view>
		</view>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				cai_id:10,
				keyword:"",
				cai_info:"",
				kehuList:[],
			}
		},
		onLoad(option){
			if(option.cai_id){
				this.cai_id = option.cai_id
			}
			
			//接口
			this.kehuAndCai();
		},
		methods: {
			
		   kehuAndCai(){
			   let parm = {
				   cai_id : this.cai_id,
				   keyword:this.keyword,
			   }
			   this.$u.api.kehuAndSchool(parm).then(res => {
					this.cai_info = res.cai_info
					this.kehuList = res.data
			   });
		   },	
		   //设置可见不可见
		   setJan(index){
			   let item = this.kehuList[index]
			   let parm = {
			   				   cai_id : this.cai_id,
			   				   user_id: item.id
			   }
			   this.$u.api.setNoUserIds(parm).then(res => {
			   				if(res.type == 1){
								this.$u.toast("设置可见成功");
							}else{
								this.$u.toast("设置不可见成功");
							}
							item.islook = res.type;
			   });
		   },
		   bindUrls(url){// 商品图片单独处理
		   	var path=this.serviceUrl+url;
		   	//var path="https://hr.gukecloud.com/"+url;
		   	//alert("path==="+path)
		   	return path;
		   }
		}
	}
</script>
<style lang="scss" scoped>
	.lineList{
		.list{height: 140rpx;display: flex;
			margin-left: 40rpx;margin-right: 40px;border-bottom: #F1F1F1 solid 1rpx;
			.leftView{flex: 1;
				line-height: 140rpx;color: #333333;font-size: 29rpx;
			}
			.rightView{
				width: 110rpx;height: 140rpx;//background: #007AFF;
				//justify-content: flex-end;
				.txt{margin-top: 46rpx;
					width: 110rpx;
					height: 50rpx;
					border: 2rpx solid #E89C38;
					border-radius: 25rpx;
					text-align: center;line-height: 50rpx;color: #E48A15;font-size: 23rpx;
				}
				.bkj{
					background-color: #E89C38;
					color: #fff;
				}
			}
		}
	}
	.topSe {
		//background: yellow;
		background: #FFF;
		height: 120rpx;
		overflow: hidden;
		width: 100%;
		.inputInfo {
			margin-top: 30rpx;
			border-radius: 30px;
			margin-left: 40rpx;
			margin-right: 40rpx;
			height: 70rpx;
			background: #F6F7FA;
			display: flex;

			.inputIcon {
				width: 50rpx;
				height: 100%; //background: red;

				.u-icon {
					margin-top: 20rpx;
					margin-left: 20rpx;
				}
			}

			.inputHtml {
				flex: 1;

				input {
					//background: green;
					padding-left: 14rpx;
					line-height: 70rpx;
					height: 70rpx;
					width: 100%;
					color: #B9B9B9;
					font-size: 24rpx;
				}

			}
		}

	}

	.line {
		width: 100%;
		height: 10rpx;
		background: #F2F2F2;
	}

	.top {
		//background: #18B566;
		height: 190rpx;
		display: flex;

		.top1 {
			margin-top: 29rpx;
			margin-left: 40rpx;

			image {
				width: 153rpx;
				height: 133rpx;
				border-radius: 10rpx;
			}
		}

		.top2 {
			margin-left: 30rpx;
			//background: yellow;
			flex: 1;
			margin-right: 35rpx;

			.top2Txt1 {
				margin-top: 54rpx;
				height: 30rpx;
				//background: #007AFF;
				color: #333333;
				font-size: 28rpx;
			}

			.top2Txt2 {
				text-align: right;
				height: 40rpx;
				line-height: 40rpx;
				//background: #18B566;
				color: #E2484A;
				font-size: 32rpx;
			}

			.top2Txt3 {
				margin-top: -10rpx;
				//background: #2C405A;
				color: #C8C8C8;
				font-size: 24rpx;
			}
		}
	}
</style>